﻿using System;
using System.IO;
using System.Xml.Linq;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace XnaXaml.Pipeline
{
    [ContentImporter(".xaml", DisplayName = "XAML File - XnaXaml", DefaultProcessor = "None")]
    class XamlSourceImporter : ContentImporter<XDocument>
    {
        public override XDocument Import(string filename, ContentImporterContext context)
        {
            var ret = new XDocument();
            try
            {
                var xmlContent = File.ReadAllText(filename);
                ret = XDocument.Parse(xmlContent);
            }
            catch (Exception ex)
            {
                var msg = "Content Importer Error:/r/n" + ex.Message + "\r\n\r\n" + ex.StackTrace;
                File.WriteAllText("c:\\ContentImporterLog.txt", msg);
            }
            
            return ret;
        }
    }
}
